package com.mnb.base.service.impl;

import com.mnb.base.entity.StRsvrfcchB;
import com.mnb.common.utils.R;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.mnb.base.mapper.StRsvrfcchBMapper;
import com.mnb.base.entity.StRsvrfcchB;
import com.mnb.base.service.StRsvrfcchBService;

import java.util.List;

@Service
public class StRsvrfcchBServiceImpl implements StRsvrfcchBService{

    @Resource
    private StRsvrfcchBMapper stRsvrfcchBMapper;

    @Override
    public int deleteByPrimaryKey(String stcd) {
        return stRsvrfcchBMapper.deleteByPrimaryKey(stcd);
    }

    @Override
    public R getList(StRsvrfcchB stRsvrfcchB) {
        List<StRsvrfcchB> list =  stRsvrfcchBMapper.getList(stRsvrfcchB);
        return R.ok(list);
    }

    @Override
    public R insert(StRsvrfcchB stRsvrfcchB) {
        StRsvrfcchB count = stRsvrfcchBMapper.selectByPrimaryKey(stRsvrfcchB.getStcd());
        if(count != null){
            return R.fail("该数据已存在");
        }
        stRsvrfcchBMapper.insert(stRsvrfcchB);
        return R.ok();
    }

    @Override
    public R udpate(StRsvrfcchB stRsvrfcchB) {
        stRsvrfcchBMapper.updateByPrimaryKey(stRsvrfcchB);
        return R.ok();
    }

}
